package com.kifas.service.dataaccess;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.kifas.entity.JenisCustomerEntity;

@Repository
public class JenisCustomerDao {
	@SuppressWarnings("unused")
	private static Logger log = Logger.getLogger(JenisCustomerDao.class);

	@Autowired
	private SessionFactory sessionFactory;

	public void insert(JenisCustomerEntity jenisCustomer) throws Exception {
		sessionFactory.getCurrentSession().save(jenisCustomer);
	}

	@SuppressWarnings("unchecked")
	public List<JenisCustomerEntity> getJenisCustomers() {
		return sessionFactory.getCurrentSession().createQuery("from JenisCustomerEntity jc").list();
	}
	
	public JenisCustomerEntity getJenisCustomer(Long idJenisCustomer) {
		return (JenisCustomerEntity) sessionFactory.getCurrentSession().get(
				JenisCustomerEntity.class, idJenisCustomer);
	}

	public void update(JenisCustomerEntity jenisCustomer)
			throws Exception {
		sessionFactory.getCurrentSession().update(jenisCustomer);
	}
}
